<?php
#**************************************************************************
#  openSIS is a free student information system for public and non-public 
#  schools from Open Solutions for Education, Inc. web: www.os4ed.com
#
#  openSIS is  web-based, open source, and comes packed with features that 
#  include student demographic info, scheduling, grade book, attendance, 
#  report cards, eligibility, transcripts, parent portal, 
#  student portal and more.   
#
#  Visit the openSIS web site at http://www.opensis.com to learn more.
#  If you have question regarding this system or the license, please send 
#  an email to info@os4ed.com.
#
#  This program is released under the terms of the GNU General Public License as  
#  published by the Free Software Foundation, version 2 of the License. 
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************************
if($_REQUEST['modfunc']=='update'){
	//cap nhat tai khoan va mat khau
	if($_REQUEST['mailbox']){
		$TOTAL_COUNT=DBGet(DBQuery("SELECT COUNT(*) AS TOTAL FROM mail_box"));
		$TOTAL_COUNT=$TOTAL_COUNT[1]['TOTAL'];
		if($TOTAL_COUNT==0 && $_REQUEST['mailbox']['EMAIL'] && $_REQUEST['mailbox']['PASSWORD']){
			DBQuery('INSERT INTO mail_box(email,password) VALUES(\''.$_REQUEST['mailbox']['EMAIL'].'\', \''.$_REQUEST['mailbox']['PASSWORD'].'\')');
		}else if($TOTAL_COUNT==1){
			$sql = 'UPDATE mail_box SET ';
			foreach($_REQUEST['mailbox'] as $column=>$value)
			{
				$sql .= $column.'=\''.str_replace("\'","''",$value).'\',';
			}
			$sql = substr($sql,0,-1);
			DBQuery($sql);
		}
	}
	unset($_REQUEST['mailbox']);
}
//lay tai khoan va mat khau de hien thi len giao dien
$mail_RET=DBGet(DBQuery('SELECT *  FROM mail_box LIMIT 1'));
$mail=$mail_RET[1];
echo "<FORM name=failure id=failure action=Modules.php?modname=$_REQUEST[modname]&modfunc=update&page_display=MAILBOX method=POST>";
echo '<table width="330px;" cellpadding="4">';
echo '<tr><td width="50%" align="right">Email address of mail box:</td><td align="left">'.TextInput($mail['EMAIL'],'mailbox[EMAIL]','','class=cell_floating').'</td></tr>';
echo '<tr><td width="50%" align="right">Password of mail box:</td><td align="left">'.TextInput($mail['PASSWORD'],'mailbox[PASSWORD]','','class=cell_floating').'</td></tr>';
echo '<tr><td colspan="2"></td></tr>';
echo '<tr><td colspan="2"><CENTER>'.SubmitButton('Save','','class=btn_medium').'</CENTER></td></tr>';
echo '</table>';
echo '</FORM>';





